package ynu.edu.controller;

import org.springframework.web.bind.annotation.*;
import ynu.edu.Feign.ProviderClient;
import java.util.Map;

@RestController
@RequestMapping("/feign")
public class FeignController {

    private final ProviderClient providerClient;

    public FeignController(ProviderClient providerClient) {
        this.providerClient = providerClient;
    }

    @GetMapping("/get/{id}")
    public String feignGet(@PathVariable("id") String id) {
        return providerClient.getData(id);
    }

    @PostMapping("/create")
    public String feignCreate(@RequestBody Map<String, String> data) {
        return providerClient.createData(data);
    }

    @PutMapping("/update/{id}")
    public String feignUpdate(@PathVariable("id") String id, @RequestBody Map<String, String> data) {
        return providerClient.updateData(id, data);
    }

    @DeleteMapping("/delete/{id}")
    public String feignDelete(@PathVariable("id") String id) {
        return providerClient.deleteData(id);
    }
}
